<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$this->model('model')->check_worker();
if($_RQ['op']=='get'){
	$month=$_RQ['month'];
	if(!$month){
		exi('请选择月份！','erroe');
	}
	$yuestart = strtotime($month);
	$yueend = strtotime("$month +1 month -1 day");
	$params=array('ispay'=>1,'uniacid'=>$_SESSION['uniacid']);
	$params['createtime between']=array($yuestart,$yueend);
	$num=pdo_count('jy_weishop_order',$params);
	$fee=pdo_getsum('jy_weishop_order',$params,'price');
	$return['params']=array(
		'num'=>$num,
		'fee'=>$fee,
		'yuestart'=>$yuestart,
		'yueend'=>$yueend,
		'month'=>$month
	);
	set_html('title',$month.'明细');
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$params=array('ispay'=>1,'uniacid'=>$_SESSION['uniacid']);
	$yuestart = $_RQ['yuestart'];
	$yueend = $_RQ['yueend'];
	$params['createtime between']=array($yuestart,$yueend);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['list']=pdo_getslice('jy_weishop_order',$params,array($pindex,$psize),$total,array(),'','createtime desc');
	foreach($return['list'] as $k=>&$item){
		$item['days'] = date('Y-m-d',$item['createtime']);
		$item['createtime']=date('Y-m-d',$item['createtime']);
		$item['member']=cfc('core')->member_show($item['mid']);
		$ordergoods=pdo_getall('jy_weishop_order_goods',array('orderid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']),array('goodsid','optionid','price','total','goodssn','productsn'));
		foreach($ordergoods as &$gv){
			$goodsinfo = pdo_get('jy_weishop_goods',array('id'=>$gv['goodsid'],'uniacid'=>$_SESSION['uniacid']),array('id','marketprice','unit','image','title','merchid'));
			$goodsinfo['total']=$gv['total'];
			$goodsinfo['price']=$gv['price'];
			if($_SESSION['is_tomedia']){
				$goodsinfo['image']=$goodsinfo['image']?tomedia($goodsinfo['image']):'';
			}
			$goodsinfo['weight']=pdo_getcolumn('jy_weishop_goods_dispatch',array('goodsid'=>$gv['goodsid']),'weight');
			//商品规格
			if($gv['optionid']){
				$specs=pdo_getcolumn('jy_weishop_goods_option',array('id'=>$gv['optionid']),'specs');
				$specs=explode("_",$specs);
				foreach($specs as &$spec){
					$spec=pdo_getcolumn('jy_weishop_goods_spec_item',array('id'=>$spec),'title');
				}
				$goodsinfo['selespename']=implode("，",$specs);
			}
			//获取商户
			if($goodsinfo['merchid']){
				$merchinfo = pdo_get('jy_merch_user',array('id'=>$goodsinfo['merchid'],'uniacid'=>$_SESSION['uniacid']));
				$goodsinfo['merchname'] = $merchinfo['merchname'];
			}
			$item['goodsinfo']=$goodsinfo;
		}
	}
	exi($return);
}